/*! Bitstr.h */
#pragma once

#include <iostream>
#include <string>
#include <iomanip>
#include "Bit.h"

using namespace std;

class Bitstr : Bit
{
public:
	/*! Empty constructor */
	Bitstr(void) {}
	/*! Empty destructor */
	~Bitstr(void) {}
	
	/*! Adds astr and bstr to sumstr */
	void addStr(string astr, string bstr, string &sumstr)
	{
		char ci = '0';
		char cu = '0';
		char sum = '0';
		sumstr.resize(astr.size());

		if(sizeof(astr) == sizeof(bstr))
		{
			for(int i = astr.size()-1; i >=0; i--)
			{
				add(astr[i], bstr[i], ci, sum, cu);
				ci = cu;
				sumstr[i] = sum;
			}
		}
	}

	/* Calculates the two-complement of the string str */
	void twoComplement(string &str)
	{
		string invert_str = str;
		string addOne;

		for(int i = 0; i < invert_str.size(); i++)
		{
			invert_str[i] = not(invert_str[i]);
		}

		for(int i = 0; i < invert_str.size()-1; i++)
		{
			addOne.push_back('0');
		}
		addOne.push_back('1');
		addStr(invert_str, addOne, str);
	}

};